const jwt = require('jsonwebtoken');
const fs = require('fs');
const path = require('path');

module.exports = (data,time) => {
  let create = Math.floor(Date.now() / 1000);
  let cert = fs.readFileSync(path.join(__dirname,'../rsa/rsa_private_key.pem'));
  const token = jwt.sign({
    data,
    exp: create + time,
  },
  cert,
  {algorithm: 'RS256'}
  );
  return token;
}